package com.manage.demo.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.manage.demo.dao.model.ExamResults;

@Mapper
public interface MangeintoMapper {
	
	@Select("select * from exam_results where id=#{id}")
	public ExamResults getResult(String id);

	@Select("select stu_id from student_info where grade='1' and class_num='1'")
	public List<String> getStu11();
	@Select("select stu_id from student_info where grade='1' and class_num='2'")
	public List<String> getStu12();
	@Select("select stu_id from student_info where grade='1' and class_num='3'")
	public List<String> getStu13();
	@Select("select stu_id from student_info where grade='1' and class_num='4'")
	public List<String> getStu14();
	@Select("select stu_id from student_info where grade='1' and class_num='5'")
	public List<String> getStu15();
	@Select("select stu_id from student_info where grade='2' and class_num='1'")
	public List<String> getStu21();
	@Select("select stu_id from student_info where grade='2' and class_num='2'")
	public List<String> getStu22();
	@Select("select stu_id from student_info where grade='2' and class_num='3'")
	public List<String> getStu23();
	@Select("select stu_id from student_info where grade='2' and class_num='4'")
	public List<String> getStu24();
	@Select("select stu_id from student_info where grade='2' and class_num='5'")
	public List<String> getStu25();
	@Select("select stu_id from student_info where grade='3' and class_num='1'")
	public List<String> getStu31();
	@Select("select stu_id from student_info where grade='3' and class_num='2'")
	public List<String> getStu32();
	@Select("select stu_id from student_info where grade='3' and class_num='3'")
	public List<String> getStu33();
	@Select("select stu_id from student_info where grade='3' and class_num='4'")
	public List<String> getStu34();
	@Select("select stu_id from student_info where grade='3' and class_num='5'")
	public List<String> getStu35();
	
	@Select("select * from exam_results where stu_id=#{stu_id} and term=#{term} and exam_type=#{exam_type}")
	public List<ExamResults> getExamResults(String stu_id, String term, String exam_type);
	
	@Update("update exam_results set chinese=#{result} where stu_id=#{stu_id} and term=#{term} and exam_type=#{exam_type}")
	public Integer updateChinsesExamResults(String result, String stu_id, String term, String exam_type);
	
	@Update("update exam_results set math=#{result} where stu_id=#{stu_id} and term=#{term} and exam_type=#{exam_type}")
	public Integer updateMathExamResults(String result, String stu_id, String term, String exam_type);
	
	@Update("update exam_results set english=#{result} where stu_id=#{stu_id} and term=#{term} and exam_type=#{exam_type}")
	public Integer updateEnglishExamResults(String result, String stu_id, String term, String exam_type);
	
	@Update("update exam_results set physics=#{result} where stu_id=#{stu_id} and term=#{term} and exam_type=#{exam_type}")
	public Integer updatePhysicsExamResults(String result, String stu_id, String term, String exam_type);
	
	@Update("update exam_results set chemistry=#{result} where stu_id=#{stu_id} and term=#{term} and exam_type=#{exam_type}")
	public Integer updateChemistryExamResults(String result, String stu_id, String term, String exam_type);
	
	@Insert({
		"<script> ",
		"insert into exam_results ",
		"(stu_id,term,exam_type,create_time,update_time) ",
		"values ",
		"(#{stu_id},#{term},#{exam_type},now(),now())",
		"</script>"
	})
	public Integer insertExamResults(String stu_id, String term, String exam_type);
}
